<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>邮件发送</title>
    <script src="js/jquery-3.3.1.min.js"></script>
</head>
<body>
   邮件:<input type="text" id="mail"> <button onclick="sendMail()">发送</button> <br>
   验证码:<input type="text" id="code"> <br>
   <button onclick="validate()">验证</button>
</body>

</html>

<script>
    function  sendMail() {
         var m = $("#mail").val();
         $.get('/api/sendMail',{toMail:m},function (res) {
             alert('发送成功');
         });

    }


    function validate() {
        var m = $("#mail").val(); //邮件
        var c = $("#code").val();//验证码
        $.get("/api/yz",{toMail:m,code:c},function (res) {
              alert(res);
        });

    }
</script>